package cn.glc.daily.life.common.enums;

import cn.glc.daily.life.common.exceptions.Business;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 全局异常码
 * 200   ---- 100 ---- 001
 * 异常分类 ---- 模块 ---- 顺序
 *
 * @author simon
 * @date 2020/6/2 10:59
 * @copyright:
 * @modifier
 * @motto a no talent, people who have to study hard
 */
public enum GlobalCodeEnum {
    ;

    /**
     * 正常返回码
     */
    @Getter
    @AllArgsConstructor
    public enum HttpStatusEnum implements Business {
        SUCCESS("200", "success"),
        FAIL("500", "error");
        private final String code;
        private final String msg;

        @Override
        public String code() {
            return this.code;
        }

        @Override
        public String msg() {
            return this.msg;
        }
    }

    /**
     * 业务异常码
     * 200 000 001
     */
    @Getter
    @AllArgsConstructor
    public enum BusinessExceptionEnum implements Business {
        MOBILE_NOT_EMPTY("200000001", "手机号不能为空"),
        MOBILE_ERROR("200000002", "手机号不正确"),
        MAIL_NOT_EMPTY("200000003", "邮箱不能为空"),
        MAIL_ERROR("200000004", "邮箱不正确"),
        UNAUTHORIZED_ERROR("200000005", "未授权的用户"),
        TOKEN_EXPIRE_ERROR("200000006", "token has expired"),
        USER_EXISTS("200000007", "账号已存在"),
        LOGIN_FAIL("200000008", "登录失败,账号密码错误"),
        LOGIN_TYPE("200000009", "登录类型错误"),
        PARAMETER_EXCEPTION("200000010", "请求参数异常"),
        LOGIN_TYPE_EXCEPTION("200000011", "登录类型异常"),
        ;
        private final String code;
        private final String msg;

        @Override
        public String code() {
            return this.code;
        }

        @Override
        public String msg() {
            return this.msg;
        }
    }

    /**
     * 业务异常码 - 字典
     * 200 100 001
     */
    @Getter
    @AllArgsConstructor
    public enum DictBusinessExceptionEnum implements Business {
        DICT_CANT_NOT_DELETE("200100001", "字典数据不能删除"),
        ;
        private final String code;
        private final String msg;

        @Override
        public String code() {
            return this.code;
        }

        @Override
        public String msg() {
            return this.msg;
        }
    }


    /**
     * 业务异常码 - 验证码
     * 200 200 001
     */
    @Getter
    @AllArgsConstructor
    public enum CaptchaBusinessExceptionEnum implements Business {
        CAPTCHA_SEND_FAIL_EXCEPTION("200200001", "验证码发送失败"),
        CAPTCHA_EXPIRE("200200002", "验证码已过期"),
        CAPTCHA_ERROR("200200003", "验证码错误"),
        ;
        private final String code;
        private final String msg;

        @Override
        public String code() {
            return this.code;
        }

        @Override
        public String msg() {
            return this.msg;
        }
    }


    /**
     * jwt 异常码
     */
    @Getter
    @AllArgsConstructor
    public enum JwtBusinessExceptionEnum implements Business {
        USER_NOT_EXIST("200200001", "用户不存在"),
        ;
        private final String code;
        private final String msg;

        @Override
        public String code() {
            return this.code;
        }

        @Override
        public String msg() {
            return this.msg;
        }
    }

    /**
     * 系统异常码
     * 300 000 001
     */
    @Getter
    @AllArgsConstructor
    public enum SystemExceptionEnum implements Business {
        SYSTEM_EXCEPTION("300000001", "系统异常");
        private final String code;
        private final String msg;

        @Override
        public String code() {
            return this.code;
        }

        @Override
        public String msg() {
            return this.msg;
        }
    }

    /**
     * 其他异常码
     * 400 000 001
     */
    @Getter
    @AllArgsConstructor
    public enum OtherExceptionEnum implements Business {
        SUCCESS("400000001", "其他异常");
        private final String code;
        private final String msg;

        @Override
        public String code() {
            return this.code;
        }

        @Override
        public String msg() {
            return this.msg;
        }
    }
}
